﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

namespace Taxes.Taxeses
{
    public partial class TaxesImports1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [DirectMethod]
        public void DeleteFile(string fileName, string fileClientName)
        {
            try
            {
                System.IO.File.Delete(fileName);
                //X.Msg.Notify("提示", fileClientName + "已删除!").Show();
            }
            catch (Exception ex)
            {
                //X.Msg.Notify("提示", fileClientName + "删除失败!").Show();
            }
        }
        [DirectMethod]
        public void Up(string att)
        {
            var path = System.Configuration.ConfigurationManager.AppSettings["UploadPath"].ToString();
            var fileName = Server.MapPath(path + "/" + att);


            var taxes = Taxeses.Analises(fileName);
            var bll = new Taxes.BLL.levy_record();
            foreach (var t in taxes)
            {
                var levy = new Model.levy_record();
                levy.lr_code = t.Code;
                String month = DateTime.Now.Month.ToString();
                if (month.Length < 2)
                {
                    month = "0" + month;
                }
                levy.lr_ny = DateTime.Now.Year + "" + month;

                foreach (KeyValuePair<string, float> pair in t.Taxe)
                {
                    switch (pair.Key)
                    {
                        case "印花税":
                            levy.lr_yhs = (decimal)pair.Value;
                            break;
                        case "个人所得税":
                            levy.lr_grsds = (decimal)pair.Value;
                            break;
                        case "营业税":
                            levy.lr_yys = (decimal)pair.Value;
                            break;
                        case "教育费附加":
                            levy.lr_jyffj = (decimal)pair.Value;
                            break;
                        case "地方教育附加":
                            levy.lr_dfjyffj = (decimal)pair.Value;
                            break;
                        case "房产税":
                            levy.lr_fcs = (decimal)pair.Value;
                            break;
                        case "工会经费":
                            break;
                        case "城市维护建设税":
                            levy.lr_cjs = (decimal)pair.Value;
                            break;
                        case "城镇土地使用税":
                            levy.lr_tdsys = (decimal)pair.Value;
                            break;
                        case "基本养老保险费":
                            levy.lr_jbylbx = (decimal)pair.Value;
                            break;
                        case "企业所得税":
                            levy.lr_qysds = (decimal)pair.Value;
                            break;
                        case "失业保险费":
                            levy.ls_sybx = (decimal)pair.Value;
                            break;
                        case "资源税":
                            levy.lr_zys = (decimal)pair.Value;
                            break;
                        case "土地增值税":
                            levy.lr_tdzzs = (decimal)pair.Value;
                            break;
                        case "车船税":
                            levy.lr_ccs = (decimal)pair.Value;
                            break;
                        case "水利建设专项资金":
                            levy.lr_sljszxzj = (decimal)pair.Value;
                            break;
                        case "文化事业建设费":
                            levy.lr_whsyjsf = (decimal)pair.Value;
                            break;
                        case "工伤保险":
                            levy.lr_gsbx = (decimal)pair.Value;
                            break;
                        case "女工生育保险":
                            levy.ls_ngsybx = (decimal)pair.Value;
                            break;
                        case "基本医疗保险":
                            levy.ls_jbylbx = (decimal)pair.Value;
                            break;
                        case "失业保险":
                            levy.ls_sybx = (decimal)pair.Value;
                            break;
                        case "残疾人保障金":
                            levy.ls_cjrbzj = (decimal)pair.Value;
                            break;
                    }
                }
                bll.Add(levy);
            }
            X.Msg.Show(new MessageBoxConfig() { Buttons = MessageBox.Button.OK, Title = "提示", Message = "导入成功" });

        }
    }
}